<template>
  <div class="page-content padding-top">
    <list class="von-checkbox">
      <item class="item-icon-right" v-for="(item,index) in name" @click.native="selectItem(item,index)">
        {{item}}<i :class="{'icon ion-ios-checkmark-empty assertive':ind == index}"></i>
      </item>
    </list>
  </div>
</template>
<script>
import { bus } from 'bus.js'
 // ...

  export default {
    data() {
      return {
        arr:[],
        name:[],
        value:[],
        ind:null,
        params:{
          marketId:window.sess.get('userSession').marketId,
          shopId:window.sess.get('userSession').shopId || '',
          // userId:window.sess.get('userSession').userId,
          // userType:41
        }
      }
    },
    created(){
      this.getUserList();
      bus.$on('shopId', (text) => {
        this.params.shopId = text;
      });
    },
    methods: {
      getUserList(){
        if (this.params.shopId != '') {
          var _this = this;
          axios.get(baseUrl+'/controller/getUserList',{params:this.params})
          .then(function(res){
            _this.arr = res.data.result;
            for (var i = 0; i < _this.arr.length; i++) {
              _this.name.push(_this.arr[i].userName);
              _this.value.push(_this.arr[i].userId);
            }
          })
        }
        
      },
      selectItem(a,i){
        this.ind = i;
        bus.$emit('staffId', this.value[i]);
        bus.$emit('staffName', a);
      }
    },
    watch:{
      'params.shopId'(){
        this.ind = null;
        this.getUserList();
      }
    }
  }
</script>

